🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / model / src / jvmAndroidMain / kotlin / org / meshtastic / core / model / util / DateTimeActuals.kt
Displaying Raw • Download
core/model/src/jvmAndroidMain/kotlin/org/meshtastic/core/model/util/DateTimeActuals.kt df62b4fd384a7d3fb867a2879aa8a14f10cd8a29 (df62b4fd) Text, 1.60 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.model.util
Tff7b72import T7ee787org.meshtastic.core.common.util.nowInstant
Tff7b72import T7ee787org.meshtastic.core.common.util.toDate
Tff7b72import T7ee787org.meshtastic.core.common.util.toInstant
Tff7b72import T7ee787java.text.DateFormat
Tff7b72import T7ee787kotlin.time.Duration.Companion.hours
Tff7b72private Tff7b72val Te6edf3DAY_DURATION Tff7b72= T79c0ff2T79c0ff4.Te6edf3hours
T8b949e/**
* Returns a short string representing the time if it's within the last 24 hours, otherwise returns a combined short
* date/time string.
*
* @param time The time in milliseconds
* @return Formatted date/time string
*/
Tff7b72actual Tff7b72fun Td2a8ffgetShortDateTimeTb4b4b4(Te6edf3timeTb4b4b4: Tffa657LongTb4b4b4)Tb4b4b4: Tffa657String Tb4b4b4{
Tff7b72val Te6edf3instant Tff7b72= Te6edf3timeTb4b4b4.Te6edf3toInstantTb4b4b4(Tb4b4b4)
Tff7b72val Te6edf3isWithin24Hours Tff7b72= Tb4b4b4(Te6edf3nowInstant Tff7b72- Te6edf3instantTb4b4b4) Tff7b72<Tff7b72= Te6edf3DAY_DURATION
Tff7b72return Tff7b72if Tb4b4b4(Te6edf3isWithin24HoursTb4b4b4) Tb4b4b4{
Te6edf3DateFormatTb4b4b4.Te6edf3getTimeInstanceTb4b4b4(Te6edf3DateFormatTb4b4b4.Te6edf3SHORTTb4b4b4)Tb4b4b4.Te6edf3formatTb4b4b4(Te6edf3instantTb4b4b4.Te6edf3toDateTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3DateFormatTb4b4b4.Te6edf3getDateTimeInstanceTb4b4b4(Te6edf3DateFormatTb4b4b4.Te6edf3SHORTTb4b4b4, Te6edf3DateFormatTb4b4b4.Te6edf3SHORTTb4b4b4)Tb4b4b4.Te6edf3formatTb4b4b4(Te6edf3instantTb4b4b4.Te6edf3toDateTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.17s